<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <body>
        <ui:composition template="./templates/template_vendeur.xhtml">  
            <ui:define name="content">
                <c:if test="${userBean.vendeurConnected == false}">
                    Veuillez vous connecter pour accéder à cette partie
                </c:if>
                <c:if test="${userBean.vendeurConnected == true}">
                    <h1>Ajouter un produit</h1>
                    <h:form id="form">                        
                        <p:inputText id="inputsearch" 
                                     value="#{magasinBean.searchebay}" required="true" label="inputsearch">  
                            <f:validateLength minimum="2" />  
                        </p:inputText>                             
                        <h:commandButton value="Rechercher"  id="btnAdd"  action="#{magasinBean.btnsrchebay}" /> <br/> <br/>                         
                        <p:dataTable value="#{magasinBean.lazyEbay}" 
                                     var="val"
                                     rows="10"
                                     paginator="true"
                                     rowsPerPageTemplate="5,10,15"
                                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                     id="DTTableLazy"
                                     lazy="true"
                                     >
                            <p:column headerText="Photo">
                                <h:graphicImage id="imgProd" url="#{val.galleryURL}"></h:graphicImage><br />
                            </p:column>
                            <p:column headerText="Titre" width="160">
                                <h:outputText value="#{val.title}"/>
                            </p:column>
                            <p:column headerText="Prix" width="160">
                                <h:outputText value="#{val.sellingStatus.convertedCurrentPrice.value} #{val.sellingStatus.convertedCurrentPrice.currencyId}"/>
                            </p:column>
                            <p:column headerText="Informations" >
                                <h:outputLink value="#{val.viewItemURL}">Voir sur Ebay</h:outputLink>
                            </p:column>
                            <p:column headerText="E-Mall" >
                                <h:commandLink action="#{magasinBean.goToCreerProduit(val)}" value="Ajouter le produit" ></h:commandLink>
                            </p:column>
                        </p:dataTable>
                    </h:form>
                </c:if>
            </ui:define>
        </ui:composition>
    </body>
</html>

